/*
    YmsgIRC - Program enabling YMSG chat clients to use IRC
    Copyright (C) 2011 Crash Daemonicus ( crashenator -at- gmail.com )

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
/**
@file ChatRenderer.h
@brief Yahoo-chat text-formatting functions

Supplies functions useful to this program for manipulating Yahoo text formats.

The internal RendererText class-object contains multiple useful methods and is required by most ChatRenderer functions.
The object takes the form of an extension of a string-class; creation and retrieval can be seen as analogues to casting.

Most of the functionality is achieved through ChatRenderer.dll
ChatRenderer.dll was originally written for the Yahsmosis chat client project to handle formatting.
Many functions are implemented in ChatRenderer that are not imported here.
This header should be linked either to the original source or using the included ChatRenderer.lib file.

You may view its source code here: http://code.google.com/p/yahsmosis/source/browse/trunk/Source/Renderer
Or here: http://yahsmosis.googlecode.com/svn/trunk/Source/Renderer/
@author crashenator (crashenator -at- gmail.com)
*/

#pragma once

/// @brief Strips yahoo text formatting from a string
/// @details This function, for ease, actually transforms Yahoo formats into orderly HTML, then strips HTML from the text.
/// Currently, only Windows (with _WIN32 defined) is supported by this function.
/// @param [in] s A string object with yahoo formatting to be stripped
/// @retval string Success: string object with formatting stripped from it.
/// @retval s Failure: string object containing the original string (if platform unsupported)
string RendererText_StripText(const string& s);

extern "C"{
    //DLLIMPORT const char* __DebugColorFade(const char* hcolorA, const char* hcolorB);
    //DLLIMPORT int __DebugColorDiff(const char* hcolorA, const char* hcolorB);
    //DLLIMPORT const char* __DebugColorCorrect(const char* hcolorA, const char* hcolorB, int tolerance);    
    //DLLIMPORT const char* __DebugFadeTable(const char* hcolors);
        
    //DLLIMPORT int __set_ColorCorrectTolerance(int i);
    //DLLIMPORT const char* __set_ColorCorrectBase(const char* c);
        
    //DLLIMPORT int __set_SizeMax(int x);
    //DLLIMPORT int __set_SizeMin(int n);
    

	/// @brief Create a RendererText object from a string for manipulation by ChatRenderer.
	/// @details Creates a heap RendererText class-object from a string, to be used by ChatRenderer.
	/// this class-object contains multiple useful methods (internal to ChatRenderer) and is required by most ChatRenderer functions.
	/// @param [in] s C string of text (possibly containing Yahoo formatting) to be manipulated
	/// @retval void* Success: a pointer to a newly-created RendererText object.
	/// @retval NULL Failure: a RendererText object could not be created.
    DLLIMPORT void* RendererText_Create(const char* s);

	/// @brief Free a RendererText object from memory.
	/// @details Note: pRTextVoid is marked as output because of memory modification only.
	/// @param [in,out] pRTextVoid pointer to a RendererText object in heap memory.
	/// @retval 1 Success: the object was released.
	/// @retval 0 Failure: pRTextVoid was invalid.
    DLLIMPORT int RendererText_Dispose(void* pRTextVoid);

	/// @brief Retrieve a C string from a RendererText object.
	/// @param [in,out] pRTextVoid pointer to a RendererText object in heap memory.
	/// @retval "const char*" Success: C string created on the heap from contents of RendererText 
	/// @retval NULL Failure: pRTextVoid was invalid or internal conversion failed.
    DLLIMPORT const char* RendererText_Retrieve(void* pRTextVoid);


    //DLLIMPORT const char* RendererText_GetINF(void* pRTextVoid);
    //DLLIMPORT int RendererText_Escape(void* pRTextVoid);
    //DLLIMPORT int RendererText_YValidateProperties(void* pRTextVoid, int iTag, int* piStart, int* piEnd);



	/// @brief Render yahoo text formatting into HTML format.
	/// @param [in,out] pRTextVoid pointer to a RendererText object in heap memory.
	/// @retval 1 Success: RendererText contents were successfully rendered as HTML. 
	/// @retval 0 Failure: pRTextVoid was invalid.
    DLLIMPORT int RendererText_YFormatHTML(void* pRTextVoid);


    //DLLIMPORT int RendererText_HTMLIsRangeText(void* pRTextVoid,int iStart, int iEnd, int allowEscapes=1, int allowCurrent=1);
    //DLLIMPORT int RendererText_HTMLGetTextLength(void* pRTextVoid,int iStart, int iEnd);
    //DLLIMPORT int RendererText_HTMLFormatFades(void* pRTextVoid);
    //DLLIMPORT int RendererText_HTMLTextReplace(void* pRTextVoid,const char* cstrFind,const char* cstrReplace, int casesense);

	/// @brief Strip HTML formatting leaving plain text.
	/// @param [in,out] pRTextVoid pointer to a RendererText object in heap memory.
	/// @retval 1 Success: HTML was successfully stripped from the RendererText contents.
	/// @retval 0 Failure: pRTextVoid was invalid.
	DLLIMPORT int RendererText_HTMLStripFormatting(void* pRTextVoid);
}

